package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import com.lmx.repoDomain.tmodel.business.User;//huibati
import javax.persistence.*;

/**
 * 交易流水表
 */
@Entity
@Table(name = "ccd_deal_flow")
@JsonApiResource(type = "dealFlow")
public class DealFlow extends BaseEntity {
	private String code; // 编码
	private User payer; //付款方
	private User payee; //收款方
	private User initiator; //发起人
	private Double amount; //金额
	private Dicttype businessType; //交易类型
	private Task task; // 任务
	private Double payerBalance;// 付款方余额
	private Double payeeBalance;// 收款方余额
	private Integer tradeTime; //交易时间
	private PayRecord payRecord; // 支付记录
	private Integer createTime;//创建时间
	private String remark;//备注

	@Column(name = "code")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "payer_id",foreignKey = @ForeignKey(name = "null"))
	public User getPayer() {
		return payer;
	}

	public void setPayer(User payer) {
		this.payer = payer;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "payee_id",foreignKey = @ForeignKey(name = "null"))
	public User getPayee() {
		return payee;
	}

	public void setPayee(User payee) {
		this.payee = payee;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "initiator_id",foreignKey = @ForeignKey(name = "null"))
	public User getInitiator() {
		return initiator;
	}

	public void setInitiator(User initiator) {
		this.initiator = initiator;
	}

	@Column(name = "amount")
	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "business_type_id",foreignKey = @ForeignKey(name = "null"))
	public Dicttype getBusinessType() {
		return businessType;
	}

	public void setBusinessType(Dicttype businessType) {
		this.businessType = businessType;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "task_id",foreignKey = @ForeignKey(name = "null"))
	public Task getTask() {
		return task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	@Column(name = "payer_balance")
	public Double getPayerBalance() {
		return payerBalance;
	}

	public void setPayerBalance(Double payerBalance) {
		this.payerBalance = payerBalance;
	}

	@Column(name = "payee_balance")
	public Double getPayeeBalance() {
		return payeeBalance;
	}

	public void setPayeeBalance(Double payeeBalance) {
		this.payeeBalance = payeeBalance;
	}

	@Column(name = "trade_time")
	public Integer getTradeTime() {
		return tradeTime;
	}

	public void setTradeTime(Integer tradeTime) {
		this.tradeTime = tradeTime;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "pay_record_id",foreignKey = @ForeignKey(name = "null"))
	public PayRecord getPayRecord() {
		return payRecord;
	}

	public void setPayRecord(PayRecord payRecord) {
		this.payRecord = payRecord;
	}

	@Column(name = "create_time")
	public Integer getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Integer createTime) {
		this.createTime = createTime;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}
